package com.blb.community_admin.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blb.community_admin.entity.SysMenu;
import com.blb.community_admin.entity.SysUser;
import com.blb.community_admin.mapper.SysUserMapper;
import com.blb.community_admin.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {

    @Resource
    private SysUserMapper sysUserMapper;

    @Override
    public List<SysMenu> getMenusByUsername(String username) {
        return sysUserMapper.selectMenusByUsername(username);
    }

    @Override
    public IPage<SysUser> getAllUser(Page<SysUser> sysUserPage,SysUser sysUser) {
      return sysUserMapper.getAllUser(sysUserPage,sysUser);
    }

    @Override
    public void updateStatus(SysUser sysUser) {
        sysUserMapper.updateStatus(sysUser);
    }

    @Override
    public SysUser getByName(String userName) {
        return sysUserMapper.selectByName(userName);
    }

    @Override
    public void updateUserById(SysUser sysUser) {
        sysUserMapper.selectUpdateById(sysUser);
    }

    @Override
    public void updatePwdById(long userId, String newpassword) {
        sysUserMapper.updatePassword(userId,newpassword);
    }

    @Override
    public void updatePassword(SysUser sysUser) {
        sysUserMapper.selectUpdatePassword(sysUser);
    }
}
